﻿// License Notification
//======================================================
// Copyright (c) 2010 Channel Intelligence Inc.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// ======================================================




using System;
using System.Reflection;

namespace CIP4.Common
{
    [AttributeUsage(AttributeTargets.Property)]
    public class CIP4ItemModifiedTimestampAttribute : Attribute
    {
        public static CIP4ItemModifiedTimestampAttribute GetAttribute(PropertyInfo property)
        {
            object[] attributes = property.GetCustomAttributes(typeof(CIP4ItemModifiedTimestampAttribute), false);
            switch (attributes.Length)
            {
                case 0:
                    return null;

                case 1:
                    return (CIP4ItemModifiedTimestampAttribute)attributes[0];

                default:
                    throw new ApplicationException("Property has more than one CIP4ItemModifiedTimestamp attribute attached to it.");
            }
        }

    }
}
